---
title: chain
group: 'Curry'
description: Create a chain of function to run in order
---

## Basic usage

Chaining functions will cause them to execute one after another, passing the output from each function as the input to the next, returning the final output at the end of the chain.
```ts
import { chain } from 'radash'

const add = (y: number) => (x: number) => x + y
const mult = (y: number) => (x: number) => x * y
const addFive = add(5)
const double = mult(2)

const chained = chain(addFive, double)

chained(0) // => 10
chained(7) // => 24
```

### Example
```ts
import { chain } from 'radash'

type Deity = { 
  name: string
  rank: number 
}

const gods: Deity[] = [
  { rank: 8, name: 'Ra' },
  { rank: 7, name: 'Zeus' },
  { rank: 9, name: 'Loki' }
]

const getName = (god: Deity) => item.name
const upperCase = (text: string) => text.toUpperCase() as Uppercase<string>

const getUpperName = chain(
  getName, 
  upperCase
)

getUpperName(gods[0])       // => 'RA'
gods.map(getUpperName)      // => ['RA', 'ZEUS', 'LOKI']
```
